// Mod 缩写
let MOD = (domain, id, x) => (x ? `${x}x ` : "") + (id.startsWith('#') ? '#' : "") + domain + ":" + id.replace('#', '')
let CR = (id, x) => MOD("create", id, x)
let CRA = (id, x) => MOD("createaddition", id, x)
let TC = (id, x) => MOD("tconstruct", id, x)
let MC = (id, x) => MOD("minecraft", id, x)
let KJ = (id, x) => MOD("kubejs", id, x)
let FD = (id, x) => MOD("farmersdelight", id, x)
let BOP = (id, x) => MOD("biomesoplenty", id, x)
let SD = (id, x) => MOD("storagedrawers", id, x)
let SP = (id, x) => MOD("supplementaries", id, x)
let F = (id, x) => MOD("forge", id, x)
let OCC = (id, x) => MOD("occultism", id, x)
let MEK = (id, x) => MOD("mekanism", id, x)
let MEKG = (id, x) => MOD("mekanismgenerators", id, x)
let MEKT = (id, x) => MOD("mekanismtools", id, x)
let IF = (id, x) => MOD("industrialforegoing", id, x)
let TAC = (id, x) => MOD("tac", id, x)
let FAA = (id, x) => MOD("forbidden_arcanus", id, x)
let DC = (id, x) => MOD("druidcraft", id, x)
let IAF = (id, x) => MOD("iceandfire", id, x)
let TM = (id, x) => MOD("torchmaster", id, x)
let AR = (id, x) => MOD("doomangelring", id, x)
let TE = (id, x) => MOD("thermal", id, x)
let PW = (id, x) => MOD("powah", id, x)
let RS = (id, x) => MOD("refinedstorage", id, x)
let PZ = (id, x) => MOD("pipez", id, x)
let TLM = (id, x) => MOD("touhou_little_maid", id, x)
let CO = (id, x) => MOD("crossroads", id, x)
let UG = (id, x) => MOD("undergarden", id, x)
let VC = (id, x) => MOD("vanillacookbook", id, x)
//


//塞壬分泌液
onEvent('item.entity_interact', event => {
              if (event.target.type == 'iceandfire:siren' 
              && event.player.getHeldItem(event.hand) == 'minecraft:bucket')
                     {
                     event.server.runCommandSilent(`/playsound entity.cow.milk master @p ~0 0 0 16 1.0 0`)
					 event.player.mainHandItem.count-=1
					 event.player.give('kubejs:siren_milk_bucket') 
                     }            
})




onEvent('recipes', event => {
//伤害药水
event.custom(
{
  "type": "create:mixing",
  "ingredients": [
    {
      "item": "minecraft:nether_wart"
    },
    {
      "fluid": "kubejs:abyss_fountain",
      "amount": 250
    }
  ],
  "results": [
    {
      "fluid": "create:potion",
      "nbt": {
        "Bottle": "REGULAR",
        "Potion": "minecraft:harming"
      },
      "amount": 250
    }
  ],
  "heatRequirement": "heated"
})
//锌矿石
event.custom({
  "type": "interactio:item_lightning",
  "inputs": [
    {
      "item": "create:andesite_casing",
      "count": 32
    }
  ],
  "output": {
    "entries": [
      {
        "result": {
          "item": "create:zinc_ore",
          "count": 1
        },
        "weight": 99
      }
    ],
    "empty_weight": 1,
    "rolls": 1
  }
})	
//斥魂咒血
event.custom({
  "type": "tconstruct:entity_melting",
  "entity": {
    "type": IAF('gorgon')
  },
  "result": {
    "fluid": "kubejs:gorgon_blood",
    "amount": 50
  },
  "damage": 2
}).id('eow:gorgon_blood')

//汐歌芳露
event.custom(
{
  "type": "create:mixing",
  "ingredients": [
	{
      "fluid": "kubejs:siren_milk",
      "nbt": {},
      "amount": 1000
    },
	{
      "fluid": "kubejs:egg_fluid",
      "nbt": {},
      "amount": 1000
    }
  ],
  "results": [
	{
      "fluid": "kubejs:ocean_cream",
      "nbt": {},
      "amount": 1000
    }
  ],
  "heatRequirement": "heated",
}).id('eow:ocean_cream')
//青烬悬浊
event.custom(
{
  "type": "create:mixing",
  "ingredients": [
	{
      "fluid": "water",
      "nbt": {},
      "amount": 1000
    },
	{
      "item": "kubejs:dendro_ash",
      "count": 16
    }
  ],
  "results": [
	{
      "fluid": "kubejs:dendro_solution",
      "nbt": {},
      "amount": 1000
    }
  ]
}).id('eow:dendro_solution')
//甘蔗纤维
event.remove({id:CR('milling/sugar_cane')})
event.custom({
  "type": "create:milling",
  "ingredients": [
    {
      "item": "minecraft:sugar_cane"
    }
  ],
  "results": [
    {
      "item": "minecraft:sugar",
      "count": 2
    },
    {
      "item": "kubejs:sugarcane_fibre",
      "chance": 0.4
    }
  ],
  "processingTime": 50
}).id('eow:sugarcane_fibre')
//草杆
event.custom({
  "type": "farmersdelight:cutting",
  "ingredients": [
    {
      "item": "minecraft:wheat"
    }
  ],
  "tool": {
    "tag": "forge:tools/knives"
  },
  "result": [
    {
      "item": "minecraft:wheat_seeds"
    },
    {
      "item": "farmersdelight:straw"
    }
  ]
}).id('eow:straw_from_wheat')
//草木余灰
event.smoking('kubejs:dendro_ash', 'kubejs:sugarcane_fibre').xp(0.1).id('eow:dendro_ash_1')
event.smoking('kubejs:dendro_ash', 'farmersdelight:straw').xp(0.1).id('eow:dendro_ash_2')
event.smoking('9x kubejs:dendro_ash', 'farmersdelight:straw_bale').xp(0.1).id('eow:dendro_ash_3')
//玄砧裂卵
event.custom({
  "type": "interactio:item_anvil_smashing",
  "inputs": [
    {
      "item": "minecraft:egg",
      "count": 1
    }
  ],
  "output": {
    "entries": [
      {
        "result": {
          "item": "kubejs:broken_egg"
        },
        "weight": 100
      }
    ],
    "rolls": 1,
    "empty_weight": 0
  },
  "damage": 0
}).id('eow:broken_egg_from_anvil')
event.custom({
  "type": "create:pressing",
  "ingredients": [
    {
      "item": "kubejs:fake_egg"
    }
  ],
  "results": [
    {
      "item": "kubejs:broken_egg"
    }
  ]
})

//蕴生之黄
event.custom({
  "type": "create:emptying",
  "ingredients": [
    {
      "item": "kubejs:broken_egg"
    }
  ],
  "results": [
    {
      "item": "kubejs:empty_broken_egg",
      "count": 2
    },
    {
      "fluid": KJ('egg_fluid'),
      "amount": 500
    }
  ]
}).id('eow:egg_fluid')	

//混沌模拟
event.custom({
  "type": "interactio:item_lightning",
  "inputs": [
    {
      "item": "kubejs:fake_egg",
      "count": 1
    }
  ],
  "output": {
    "entries": [
      {
        "result": {
          "item": "kubejs:chaos_simulation",
          "count": 1
        },
        "weight": 99
      }
    ],
    "empty_weight": 1,
    "rolls": 1
  }
})		
		
//凋零骷髅组装
event.custom({
  "type": "create:mechanical_crafting",
  "pattern": [
    "  C  ",
    " EFE ",
    "AAAAA"
  ],
  "key": {
    "F": {
      "item": KJ('chaos_simulation')
    },
	 "E": {
      "item": KJ('wither_scrap')
    },
	 "C": {
      "item": MC('bone_meal')
    },
	 "A": {
      "item": MC('basalt')
    }
  },
  "result": {
    "item": KJ('fake_wither_skeleton')
  },
  "acceptMirrored": true
})

//汐崖之吻蛋糕
event.custom({
  "type": "create:filling",
  "ingredients": [
    {
      "item": "create:blaze_cake_base"
    },
    {
      "fluid": "kubejs:ocean_cream",
      "nbt": {},
      "amount": 1000
    }
  ],
  "results": [
    {
      "item": "kubejs:ocean_cupcake"
    }
  ]
}).id('eow:ocean_cupcake')
//锌的由来
event.custom({
  "type": "interactio:item_explode",
  "inputs": [
    {
      "item": "create:andesite_alloy",
      "count": 256
    }
  ],
  "output": {
    "entries": [
      {
        "result": {
          "item": "create:andesite_alloy",
          "count": 128
        },
        "weight": 1
      },
      {
        "result": {
          "item": "create:zinc_ore",
          "count": 1
        },
        "weight": 1
      }
    ],
    "empty_weight": 0,
    "rolls": 1
  }
})


//一片冰锌在玉壶
event.custom({
  "type": "farmersdelight:cooking",
  "ingredients": [
    {
      "item": "create:zinc_ingot"
    },
    {
      "item": "vanillacookbook:ice_cream"
    }
  ],
  "result": {
    "item": "kubejs:zincream", 
	"count": 2
  },
  "experience": 0.35,
  "cookingtime": 100
}).id('eow:zincream')
event.custom({
  "type": "farmersdelight:cooking",
  "ingredients": [
    {
      "item": "create:zinc_ingot"
    },
    {
      "item": "minecraft:snowball"
    },
    {
      "item": "minecraft:sugar"
    },
    {
      "item": "minecraft:sugar"
    },
    {
      "item": "minecraft:snowball"
    },
    {
      "item": "minecraft:sugar"
    }
  ],
  "result": {
    "item": "kubejs:zincream"
  },
  "experience": 0.35,
  "cookingtime": 100
}).id('eow:zincream_poor')
//磨出双锌
event.custom({
  "type": "create:sandpaper_polishing",
  "ingredients": [
    {
      "item": "kubejs:zincream"
    }
  ],
  "results": [
    {
      "item": "kubejs:zincouple"
    }
  ]
}).id('eow:zincouple')
//双锌分离
event.custom({
  "type": "farmersdelight:cutting",
  "ingredients": [
    {
      "item": KJ('zincouple')
    }
  ],
  "tool": {
    "tag": "forge:tools/axes"
  },
  "result": [
    {
      "item": CR('zinc_ingot'),
      "count": 2
    }
  ]
}).id('eow:zincouple_seperate')
//孳腐浓浆
event.custom({
  "type": "interactio:fluid_fluid_transform",
  "items": [
    {
      "item": "minecraft:fermented_spider_eye",
      "count": 8,
      "return_chance": 0
    },
    {
      "item": "farmersdelight:straw",
      "count": 4,
      "return_chance": 0
    }
  ],
  "input": {
    "fluid": "tconstruct:blood"
  },
  "output": {
    "entries": [
      {
        "result": {
          "fluid": "kubejs:rotten_solution"
        },
        "weight": 2
      },
      {
        "result": {
          "fluid": "kubejs:rotten_solution"
        },
        "weight": 0
      }
    ],
    "empty_weight": 0
  }
}).id('eow:rotten_solution')
event.custom({
  "type": "interactio:item_fluid_transform",
  "inputs": [
    {
      "tag": "forge:raw_meat",
      "count": 1
    }
  ],
  "fluid": {
    "fluid": "kubejs:rotten_solution"
  },
  "output": {
    "item": "minecraft:rotten_flesh",
    "count": 1
  },
  "consume_fluid": 0.10
}).id('eow:rotten_flesh_from_soluton')
//渊脉恶泉
event.custom({
  "type": "create:mixing",
  "ingredients": [
    {
      "fluid": "tconstruct:venom",
      "amount": 200
    },
    {
      "fluid": "kubejs:gorgon_blood",
      "amount": 50
    }
  ],
  "results": [
    {
      "fluid": "kubejs:abyss_fountain",
      "amount": 250
    }
  ],
  "heatRequirement": "heated"
}).id('eow:abyss_fountain')
//紫影末光
event.custom({
  "type": "create:mixing",
  "ingredients": [
    {
      "item": "minecraft:purpur_block",
      "count": 8
    },
    {
      "fluid": "industrialforegoing:ether_gas",
      "amount": 200 
    },
,
    {
      "item": "minecraft:end_stone",
      "count": 8
    }
  ],
  "results": [
    {
      "fluid": "kubejs:chorus_end",
      "amount": 100
    }
  ],
  "heatRequirement": "superheated"
}).id('eow:chrous_end')


//伪物之卵
let ebg = 'kubejs:empty_broken_egg'
event.recipes.createSequencedAssembly([
		'kubejs:fake_egg',
	], 'kubejs:empty_broken_egg', [
		event.recipes.createFilling(ebg, [ebg, Fluid.of(TC("earth_slime"), 200)]),
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("ocean_cream"), 200)])
	]).transitionalItem(ebg)
		.loops(1)
		.id('eow:fake_egg_earth')
event.recipes.createSequencedAssembly([
		'kubejs:fake_egg',
	], 'kubejs:empty_broken_egg', [
		event.recipes.createFilling(ebg, [ebg, Fluid.of(TC("sky_slime"), 200)]),
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("ocean_cream"), 200)])
	]).transitionalItem(ebg)
		.loops(1)
		.id('eow:fake_egg_sky')
event.recipes.createSequencedAssembly([
		'kubejs:fake_egg',
	], 'kubejs:empty_broken_egg', [
		event.recipes.createFilling(ebg, [ebg, Fluid.of(TC("ender_slime"), 200)]),
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("ocean_cream"), 200)])
	]).transitionalItem(ebg)
		.loops(1)
		.id('eow:fake_egg_ender')
event.recipes.createSequencedAssembly([
		'kubejs:fake_egg',
	], 'kubejs:empty_broken_egg', [
		event.recipes.createFilling(ebg, [ebg, Fluid.of(IF("pink_slime"), 100)]),
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("ocean_cream"), 200)])
	]).transitionalItem(ebg)
		.loops(1)
		.id('eow:fake_egg_pink')
event.recipes.createSequencedAssembly([
		'kubejs:fake_egg',
	], 'kubejs:empty_broken_egg', [
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("egg_fluid"), 200)]),
		event.recipes.createFilling(ebg, [ebg, Fluid.of(KJ("ocean_cream"), 200)])
	]).transitionalItem(ebg)
		.loops(1)
		.id('eow:fake_egg_yellow')
		
//伪末影人
let cst = 'kubejs:chaos_simulation'
event.recipes.createSequencedAssembly([
		'kubejs:fake_enderman',
	], 'kubejs:chaos_simulation', [
		event.recipes.createDeploying(cst, [cst, KJ('dendro_essence')]),
		event.recipes.createFilling(cst, [cst, Fluid.of(KJ("ocean_cream"), 200)]),
		event.recipes.createDeploying(cst, [cst, UG('carved_gloomgourd')])
	]).transitionalItem(cst)
		.loops(1)
		.id('eow:fake_enderman')
//伪末影人2
event.recipes.createSequencedAssembly([
		'kubejs:fake_enderman',
	], 'kubejs:chaos_simulation', [
		event.recipes.createDeploying(cst, [cst, KJ('dendro_essence')]),
		event.recipes.createFilling(cst, [cst, Fluid.of(KJ("ocean_cream"), 200)]),
		event.recipes.createDeploying(cst, [cst, TC('enderman_head')])
	]).transitionalItem(cst)
		.loops(1)
		.id('eow:fake_enderman2')
		
//重塑鸡蛋
event.recipes.createSequencedAssembly([
		'minecraft:egg',
	], 'kubejs:chaos_simulation', [
		event.recipes.createDeploying(cst, [cst, MC('wheat_seeds')]),
		event.recipes.createDeploying(cst, [cst, MC('wheat_seeds')])
	]).transitionalItem(cst)
		.loops(2)
		.id('eow:egg_back')

//汐崖之吻蛋糕
let bcb = 'create:blaze_cake_base'
event.recipes.createSequencedAssembly([
		'kubejs:ocean_cupcake',
	], 'create:blaze_cake_base', [
		event.recipes.createDeploying(bcb, [bcb, VC('jelly')]),
		event.recipes.createFilling(bcb, [bcb, Fluid.of(KJ("ocean_cream"), 500)]),
		event.recipes.createDeploying(bcb, [bcb, UG('droopvine_item')])
	]).transitionalItem(bcb)
		.loops(2)
		.id('kubejs:ocean_cupcake')

//幽冥宝章
event.recipes.createSequencedAssembly([
	KJ("nether_token"),
	], KJ('piglin_token'), [
		event.recipes.createFilling(KJ('piglin_token'), [KJ('piglin_token'), Fluid.of(CO("distilled_water"), 1000)]),
		event.recipes.createFilling(KJ('piglin_token'), [KJ('piglin_token'), Fluid.of(TC("molten_gold"), 36)])
	]).transitionalItem(KJ('piglin_token'))
		.loops(4)
		.id('eow:nether_token')

//凋零残骨
event.custom({
	"type": "crossroads:mill",
	"input": {
		"item": "tconstruct:necrotic_bone"
	},
	"output": {
		"item": "kubejs:wither_scrap",
		"count": 2
	}
}).id('eow:wither_scrap_tc')

event.custom({
	"type": "crossroads:mill",
	"input": {
		"item": "iceandfire:witherbone"
	},
	"output": {
		"item": "kubejs:wither_scrap",
		"count": 2
	}
}).id('eow:wither_scrap_iaf')


//地脉古闻
event.custom({
  "type": "interactio:item_lightning",
  "inputs": [
    {
      "item": "kubejs:nether_token",
      "count": 16
    },
    {
      "item": "kubejs:wither_scrap",
      "count": 2
    }
  ],
  "output": {
    "entries": [
      {
        "result": {
          "item": "kubejs:nether_memory",
          "count": 1
        },
        "weight": 1
      }
    ],
    "empty_weight": 3,
    "rolls": 1
  }
}).id('eow:nether_memory')

//修改催化石
event.remove({id:UG("catalyst")})
event.remove({id:UG("smelt_catalyst")})
event.smelting('3x minecraft:diamond', 'undergarden:catalyst').xp(0.1).id('eow:diamond_duplicate')

event.shaped(Item.of(UG("catalyst"), 1), 
['DDD', 
 'DZD', 
 'DDD'],
{Z: 'minecraft:diamond', 
 D: 'kubejs:nether_memory'}).id('eow:undergarden_catalyst')

//枯荣之意
event.custom({
	"type": "crossroads:centrifuge",
	"input": {
		"fluid": "kubejs:dendro_solution",
		"amount": 1000
	},
	"output_fluid": {
		"fluid": "crossroads:dirty_water",
		"amount": 500
	},
	"output": [
		{
			"item": "kubejs:dendro_essence",
			"count": 1,
			"weight": 1
		}
	]
})
//刻蚀一念
event.custom({
  "type": "interactio:item_fluid_transform",
  "inputs": [
    {
      "item": "create:shadow_steel",
      "count": 64,
      "return_chance": 0.00
    }
  ],
  "fluid": {
    "fluid": "kubejs:abyss_fountain"
  },
  "output": {
    "entries": [
      {
        "result": {
          "item": "minecraft:diamond",
          "count": 1
        },
        "weight": 4
      },
      {
        "result": {
          "item": "kubejs:carved_thought",
          "count": 1
        },
        "weight": 5
      }
    ],
    "empty_weight": 1,
    "rolls": 1
  },
  "consume_fluid": 1.0
})



//创生银莲花组装
event.custom({
  "type": "create:mechanical_crafting",
  "pattern": [
    "CCCCCCCCC",
    "CEEEEEEEC",
    "CEFFFFFEC",
    "CEFWWWFEC",
    "CEFWMWFEC",
    "CEFWWWFEC",
    "CEFFFFFEC",
    "CEEEEEEEC",
    "CCCCCCCCC"
  ],
  "key": {
    "F": {
      "item": UG('goo_block')
    },
	 "E": {
      "item": KJ('carved_thought')
    },
	 "C": {
      "item": MEK('pellet_antimatter')
    },
	 "M": {
      "tag": "eow:dragonsteel"
    },
	 "W": {
      "item": UG("catalyst")
    }
  },
  "result": {
    "item": KJ('creation_anemone')
  },
  "acceptMirrored": true
})



})


//试做末影人
onEvent('block.right_click', event => {
if (event.block == 'minecraft:obsidian' && event.player.getHeldItem(event.hand) == 'kubejs:fake_enderman')
{
event.server.runCommandSilent(`particle minecraft:spit ${event.block.x} ${event.block.y + 0.2} ${event.block.z} 1 0.4 0.4 1 1`)
event.server.runCommandSilent(`summon minecraft:enderman ${event.block.x} ${event.block.y} ${event.block.z+0.1}`)
event.server.runCommandSilent(`summon minecraft:enderman ${event.block.x+0.1} ${event.block.y} ${event.block.z}`)
event.server.runCommandSilent(`summon minecraft:enderman ${event.block.x-0.1} ${event.block.y} ${event.block.z}`)
event.server.runCommandSilent(`summon minecraft:enderman ${event.block.x} ${event.block.y} ${event.block.z-0.1}`)
event.server.runCommandSilent(`setblock ${event.block.x} ${event.block.y} ${event.block.z} minecraft:air`)
}            
})
//试做凋灵骷髅
onEvent('block.right_click', event => {
if (event.block == 'minecraft:red_nether_bricks' && event.player.getHeldItem(event.hand) == 'kubejs:fake_wither_skeleton')
{
event.server.runCommandSilent(`particle minecraft:spit ${event.block.x} ${event.block.y + 0.2} ${event.block.z} 1 0.4 0.4 1 1`)
event.server.runCommandSilent(`summon minecraft:wither_skeleton ${event.block.x-0.1} ${event.block.y} ${event.block.z}`)
event.server.runCommandSilent(`summon minecraft:wither_skeleton ${event.block.x+0.1} ${event.block.y} ${event.block.z}`)
event.server.runCommandSilent(`setblock ${event.block.x} ${event.block.y} ${event.block.z} minecraft:air`)
}             
})

//+114514
onEvent('block.right_click', event => {

if(event.block=='tconstruct:manyullyn_block'
&& event.player.offHandItem=='minecraft:nether_star'
&& event.player.mainHandItem!='tconstruct:manyullyn_block'
&& event.player.getHeldItem(event.hand).nbt.Unbreakable!=1)
{
event.server.runCommandSilent(`setblock ${event.block.x} ${event.block.y} ${event.block.z} minecraft:air`)
event.player.offHandItem.count-=1
event.player.getHeldItem(event.hand).nbt.Unbreakable=1
event.server.runCommand(`say 恭喜本服大神玩家${event.player}强化出了+114514【${event.player.getHeldItem(event.hand).name}】！！`)
}           
})

//监听玩家获取自定义奖励事件
events.listen('ftbquests.custom_reward', function (event) {
    let reward = event.getReward()
    let id = reward.quest.getCodeString()

    let runCommand = (cmd) => {
        event.server.schedule(10, event.server, function (callback) {
            callback.data.runCommandSilent(cmd)
        })
    }

    if (reward.hasTag('reset'))
        runCommand('/ftbquests change_progress ' + event.player.name + ' reset ' + id)

    if (reward.hasTag('bad_omen'))
        runCommand('/effect clear ' + event.player.name + ' minecraft:bad_omen')

    if (reward.hasTag('fortress'))
        event.server.schedule(10, event.server, function (callback) {
            callback.data.runCommand('/execute as ' + event.player.name + ' in minecraft:the_nether run locate fortress')
        })

})




